package com.dzu.medium;

/**
 * @author ZhaoDong
 * @date 2022/10/21 11:22
 * @description 537. 复数乘法
 */
public class Test537 {
    public static void main(String[] args) {
        System.out.println(complexNumberMultiply("1+1i", "1+1i"));
    }

    public static String complexNumberMultiply(String num1, String num2) {

        String[] split = num1.split("\\+");
        int a = Integer.parseInt(split[0]);
        String str = split[1];
        int b = Integer.parseInt(str.substring(0, str.length() - 1));

        String[] split2 = num2.split("\\+");
        int c = Integer.parseInt(split2[0]);
        String str2 = split2[1];
        int d = Integer.parseInt(str2.substring(0, str2.length() - 1));
        return (a * c - b * d) + "+" + (b * c + a * d) + "i";

    }


}
